//TestListener.cpp
#include "EventRegistry.h"
#include <iostream>
using namespace std;
class TestListener : public Listener
{
public:
	TestListener();
	void handleMessage(int inMessage) const;

	mutable bool fMessage0Received;
	mutable bool fUnknownMessageReceived;
};

TestListener::TestListener()
{
	fMessage0Received = false;
	fUnknownMessageReceived = false;

	EventRegistry::registerListener(0,this);
};

void TestListener::handleMessage(int inMessage) const
{
	switch(inMessage){
	case 0:
		fMessage0Received = true;
		break;
	default:
		fUnknownMessageReceived = true;
		break;
	}
}

int main()
{
	TestListener t1;
	EventRegistry::handleMessage(0);
	EventRegistry::handleMessage(0);

	if(!t1.fMessage0Received) {
		cout << "Test Failed: Message 0 was not received" << endl;
	}
	else if(t1.fUnknownMessageReceived) {
		cout << "Test Failed: TestListener received unknown message" << endl;
	}
	else {
		cout << "Test Passed" << endl;
	}
}